﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKArchUtils.Utils;
using YJKRevitBase.WinForm;
using YJKRevitView;

namespace YJKRevitArea.AreaSet
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdCreateFillAreaByRoom : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			CmdViewType types = CmdViewType.AreaPlan;
			if (SwitchView.SetUsableView(types, commandData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			if (AreaInfoCreator._hWndRevit == null)
			{
                AreaInfoCreator._hWndRevit = new WindowHandle(Process.GetCurrentProcess().MainWindowHandle);
			}
			this.m_Revit = commandData;
			HideWarningAndErroringKit @object = new HideWarningAndErroringKit(new List<string>
			{
				"create area"
			}, HideWarningAndErroringKit.HideKitEnum.HideWarning);
			this.m_Revit.Application.Application.FailuresProcessing += @object.OnFailuresProcessing;
			return new AreaInfoCreator(this.m_Revit).CreateFillAreaByRoom(ref message);
		}

		private ExternalCommandData m_Revit;
	}
}
